package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.LuntaiEmployeeInfo;
import com.ruoyi.system.service.ILuntaiEmployeeInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 员工信息，关联adminController
 * 
 * @author ruoyi
 * @date 2025-02-17
 */
@RestController
@RequestMapping("/system/employeeInfo")
public class LuntaiEmployeeInfoController extends BaseController
{
    @Autowired
    private ILuntaiEmployeeInfoService luntaiEmployeeInfoService;

    /**
     * 查询员工信息，关联admin列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(LuntaiEmployeeInfo luntaiEmployeeInfo)
    {
        startPage();
        List<LuntaiEmployeeInfo> list = luntaiEmployeeInfoService.selectLuntaiEmployeeInfoList(luntaiEmployeeInfo);
        return getDataTable(list);
    }

    /**
     * 导出员工信息，关联admin列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:export')")
    @Log(title = "员工信息，关联admin", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LuntaiEmployeeInfo luntaiEmployeeInfo)
    {
        List<LuntaiEmployeeInfo> list = luntaiEmployeeInfoService.selectLuntaiEmployeeInfoList(luntaiEmployeeInfo);
        ExcelUtil<LuntaiEmployeeInfo> util = new ExcelUtil<LuntaiEmployeeInfo>(LuntaiEmployeeInfo.class);
        util.exportExcel(response, list, "员工信息，关联admin数据");
    }

    /**
     * 获取员工信息，关联admin详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(luntaiEmployeeInfoService.selectLuntaiEmployeeInfoById(id));
    }

    /**
     * 新增员工信息，关联admin
     */
    @PreAuthorize("@ss.hasPermi('system:info:add')")
    @Log(title = "员工信息，关联admin", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody LuntaiEmployeeInfo luntaiEmployeeInfo)
    {
        return toAjax(luntaiEmployeeInfoService.insertLuntaiEmployeeInfo(luntaiEmployeeInfo));
    }

    /**
     * 修改员工信息，关联admin
     */
    @PreAuthorize("@ss.hasPermi('system:info:edit')")
    @Log(title = "员工信息，关联admin", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody LuntaiEmployeeInfo luntaiEmployeeInfo)
    {
        return toAjax(luntaiEmployeeInfoService.updateLuntaiEmployeeInfo(luntaiEmployeeInfo));
    }

    /**
     * 删除员工信息，关联admin
     */
    @PreAuthorize("@ss.hasPermi('system:info:remove')")
    @Log(title = "员工信息，关联admin", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(luntaiEmployeeInfoService.deleteLuntaiEmployeeInfoByIds(ids));
    }
}
